package com.neusoft.demo.component;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class myWebMvcConfigurer implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/toLogin").setViewName("login");//控制页面跳转到login页面
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //控制拦截规则
        registry.addInterceptor(new loginHandlerInterceptor()).addPathPatterns("/admin/**")
                .excludePathPatterns("/toLogin","/admin/login");
    }
}
